<?php
namespace App\Library\System\Model;

use App\Library\System\Model;

class AjaxModel extends Model
{
    private static $static_ajax;

    public static function getInstance()
    {
        if (!self::$static_ajax) {
            self::$static_ajax = new AjaxModel();
        }

        return self::$static_ajax;
    }

    public function updateAvatar($avatar)
    {
        $this->non($this->update()
                ->table('avatar')
                ->set(array(
                    'x' => $avatar->x,
                    'y' => $avatar->y,
                    's' => $avatar->s
                ))
        );
    }

    public function searchUser($keyword)
    {
        /*
        $this->more($this->select()
                         ->from('user')
                         ->where(

                          )
        );
        */
    }

    public function isExistedEmail($email)
    {
        $user = $this->one($this->select()
            ->from('user')
            ->where(array(
                'email' => $email
            )));

        return is_object($user);
    }

    public function getWidgetContent($id)
    {
        return 'abc';
    }
}